<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>杨义权的博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    {{ template "common/link.html" }}
</head>
<body class="lay-blog">
<canvas id="Mycanvas"></canvas>
<script src="/static/js/bg.js"></script>
<div class="container-wrap">
    <div class="container" style="width:750px;position: absolute;left: 33%; top: 33%">
        <div class="contar-wrap">
            <div class="item">
                <div class="item-box  layer-photos-demo2 layer-photos-demo">
                    <form class="layui-form" action="">
                        <h1 style="color: #5a6268;text-align: center;margin-bottom: 5px">BlogRegister</h1>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新的账号</label>
                            <div class="layui-input-block">
                                <input type="text" name="username"  placeholder="请输入账号" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">新的密码</label>
                            <div class="layui-input-inline">
                                <input type="password" name="password"  placeholder="请输入密码" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">密码可以字母数字以及特殊字符，不能超过16位</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">确认密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="rpassword"  placeholder="请再次输入密码" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">邮箱</label>
                            <div class="layui-input-block">
                                <input type="text" name="email"  placeholder="请输入邮箱" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="reg">保存</button>
                                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{{ template "common/footer.html" . }}
<script src="/static/layui/layui.js"></script>
<script language="JavaScript">
    layui.use(['form','jquery'], function(){
        var form = layui.form,
            $=layui.$;
        form.render();
        //监听提交
        form.on('submit(reg)', function(rdata){
            $.post("/user/reg",rdata.field,function (data){
                if (data.code===0){
                    layer.msg("注册成功");
                    if(data.action){
                        setTimeout(function (){
                            window.location.href=data.action
                        },300)
                    }
                }else {
                    layer.msg(data.msg);
                }
            },"json").error(function (){
                layer.msg("网络异常");
            })
            return false;
        })
    })
</script>
</body>
</html>